package com.wswy.wyjk.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.wswy.wyjk.R;

public class GlideUtils {

    public static void load(Context context, String url, ImageView imageView, boolean isCircle) {
        load(context, url, imageView, R.drawable.login_head, R.drawable.login_head, isCircle);
    }

    public static void load(Context context, String url, ImageView imageView) {
        load(context, url, imageView, R.drawable.login_head, R.drawable.login_head, false);
    }

    public static void load(Context context, String url, ImageView imageView, int placePic, int errPic) {
        load(context, url, imageView, placePic, errPic, false);
    }

    public static void load(Context context, String url, ImageView imageView, int placePic) {
        load(context, url, imageView, placePic, placePic, false);
    }

    public static void load(Context context, String url, ImageView imageView, int placePic, boolean isCircle) {
        load(context, url, imageView, placePic, placePic, isCircle);
    }

    public static void load(Context context, String url, ImageView imageView, int placePic, int errPic, boolean isCircle) {
        RequestOptions option;
        if (isCircle) {
            option = RequestOptions.placeholderOf(placePic)
                    .bitmapTransform(new CircleCrop())
                    .error(errPic);
        } else {
            option = RequestOptions.placeholderOf(placePic)
                    .error(errPic);
        }
        Glide.with(context).load(url).apply(option)
                .into(imageView);
    }
}
